package com.andaily.domain.shared;

import org.apache.commons.lang.StringUtils;
import org.springframework.util.Assert;

import java.util.Arrays;
import java.util.List;

/**
 * @author Shengzhao Li
 */
public class Application {

    private static String host;

    private static String incomeAccountTypeGuid;

    private static String defaultAccountTypeGuid;

    private static List<String> cookingAccountUserGuids;

    //default constructor
    public Application() {
    }

    public static List<String> cookingAccountUserGuids() {
        return cookingAccountUserGuids;
    }

    public static String defaultAccountTypeGuid() {
        return defaultAccountTypeGuid;
    }

    public static String host() {
        return host;
    }

    public static String incomeAccountTypeGuid() {
        return incomeAccountTypeGuid;
    }

    public void setIncomeAccountTypeGuid(String incomeAccountTypeGuid) {
        Application.incomeAccountTypeGuid = incomeAccountTypeGuid;
    }

    public void setDefaultAccountTypeGuid(String defaultAccountTypeGuid) {
        Assert.notNull(defaultAccountTypeGuid, "defaultAccountTypeGuid is required");
        Application.defaultAccountTypeGuid = defaultAccountTypeGuid;
    }

    public void setHost(String host) {
        Application.host = host;
    }

    public void setCookingAccountUserGuids(String cookingAccountUserGuids) {
        Assert.notNull(cookingAccountUserGuids, "cookingAccountUserGuids is required");
        String[] guids = StringUtils.split(cookingAccountUserGuids, ",");
        Application.cookingAccountUserGuids = Arrays.asList(guids);
    }
}
